home *** CD-ROM | disk | FTP | other *** search
/ Cracking 2 / Cracking II..iso / Texty / crackme / SiFLyiNG_9.txt < prev    next >
Encoding:
Text File  |  1999-08-12  |  11.3 KB  |  256 lines

  1.  
  2.         SiFLyiNG
  3.              Tutorial #9
  4.  
  5. ____________________________________________________________________________
  6.  
  7. Target          : Liquid Crackme 1
  8.                 d/l it on http://crackmes.cjb.net
  9. Protection type : Serial/name
  10. Level           : Classic serial generation
  11. Tools needed    : I've only use SoftIce
  12.                 Basis of cracking
  13.                 A brain (optional ;)
  14.                 Punk mp3 (Bad religion & Millencolin for the moment)
  15.                 I must be enough... :)
  16. ____________________________________________________________________________
  17.  
  18. Before beginning...
  19.  
  20.         This crackme is 'classic'. I mean it's a Serial/name protection and
  21. the serial is generated from the name. All the char are used for this
  22. calculation. I have nothing more to say as introduction... Time is money,
  23. so let's start.
  24.  
  25. ____________________________________________________________________________
  26.  
  27. The essay...
  28.  
  29.         There are two textbox in the main form of the crackme :
  30. 1. "Enter your name here:" : name
  31. 2. "And the serial is:"    : serial
  32.  
  33.         So we'll complete them with 'SiFLyiNG' and '12345678'. A 'bpx hmemcpy'
  34. in Softice will be better, then we just press the check button and we're back
  35. to SoftIce. From there you press F11 one time to return to the caller, and
  36. F12 til you see at the bottom of the code window :
  37.  
  38.         CRACKME1!CODE+00026242 (i believe you'll see the same...)
  39.  
  40. NB: if we had just wanted to get the real serial for our name, we would have
  41. to make another F5 and follow the same step afterwards (F11 and F12), so that
  42. the crackme could have got the two entries (name and serial). There, we would
  43. have arrived just at the beginning of the serial check, and it would have been
  44. easy to get the valid serial from there. But we won't just get a valid serial,
  45. we'll see the calculation routine too, in order to code a keygen.
  46.  
  47.         So, now you should see this piece of code :
  48.  
  49. :00427239 lea edx, dword ptr [ebp-10]
  50. :0042723C mov eax, dword ptr [edi+000001B4]
  51. :00427242 call 00411AC8             ; get the entered name
  52. :00427247 mov eax, dword ptr [ebp-10] ; <-- Here you land
  53.                                 ; after this line, eax points to the name
  54. :0042724A call 00403380 ; this call returns the len of the entered name
  55. :0042724F mov dword ptr [ebp-04], eax    ; stores the lenght of name
  56. :00427252 cmp dword ptr [ebp-04], 00000004 ; compare the lenght with 4
  57. :00427256 jge 00427272            ; lenght must be superior or equal to 4
  58.                                 ; if it's the case, jump and go on checking
  59.                                 ; otherwise, displays a message box :
  60.                   ; "Your name must have at least 4 characters!"
  61. :00427258 push 00000000
  62. :0042725A mov cx, word ptr [00427354]
  63. :00427261 xor edx, edx
  64. :00427263 mov eax, 00427360
  65. :00427268 call 00426CAC   ; displays the message box
  66. :0042726D jmp 00427327    
  67.  
  68. Fortunately, the lenght of name 'SiFLyiNG' is longer than 4 characters, so we
  69. jump from 427256 to 427272 and we arrive here:
  70.  
  71. :00427272 mov eax, dword ptr [ebp-04]   ; eax = lenght of name
  72. :00427275 test eax, eax                 ; check if name entered
  73. :00427277 jle 004272CE                  ; jump to bad cracker
  74. :00427279 mov dword ptr [ebp-0C], eax   ; store the lenght of name in [EBP-0C]
  75. :0042727C mov esi, 00000001             ; esi = 1
  76.  
  77.        OK, this is not interesting for the moment but if we trace a bit in
  78. the code, we arrive in a loop which begins the serial calculation :
  79.  
  80. :00427281 lea edx, dword ptr [ebp-10]
  81. :00427284 mov eax, dword ptr [edi+000001B4]
  82. :0042728A call 00411AC8                 ; this call gets the name (same as the
  83.                                         ; previous)
  84. :0042728F mov eax, dword ptr [ebp-10]     ; eax points to the name 
  85. :00427292 movzx eax, byte ptr [eax+esi-01] ; eax = ascii value of the ESIth 
  86.                                       ; char from name (from the beginning)
  87. :00427297 mov dword ptr [ebp-08], eax    ; store eax in [EBP-08]
  88. :0042729A lea edx, dword ptr [ebp-10]
  89. :0042729D mov eax, dword ptr [edi+000001B4]
  90. :004272A3 call 00411AC8                 ; this call gets the name another time
  91. :004272A8 mov eax, dword ptr [ebp-10]   ; eax points to the name
  92. :004272AB mov edx, dword ptr [ebp-04]   ; edx = lenght of name
  93. :004272AE sub edx, esi                  ; edx - esi
  94. :004272B0 movzx eax, byte ptr [eax+edx-01] ; eax = ascii value of the EDXth
  95.              ; char from the name 
  96. :004272B5 and dword ptr [ebp-08], eax   ; [EBP-08] AND EAX
  97. :004272B8 add ebx, dword ptr [ebp-08]   ; ebx = ebx+[EBP-08]
  98. :004272BB imul ebx, esi                 ; ebx * esi
  99. :004272BE test ebx, ebx                 ; check if EBX> or = 0
  100. :004272C0 jge 004272C8                  ; jump if greater or equal
  101. :004272C2 mov eax, ebx                    ; eax= ebx
  102. :004272C4 neg eax                         ; takes the two's complement of eax
  103. :004272C6 mov ebx, eax                    ; ebx = eax
  104. :004272C8 inc esi                       ; next char
  105. :004272C9 dec [ebp-0C]       ; dec [ebp-0C] (equal to lenght at the beginning
  106. :004272CC jne 00427281       ; if there are char left -> loop again
  107.                              ; otherwise, finish the loop
  108.  
  109.         Waouhh... we are near the end :) This loop is the main part of the
  110. calculation routine. I explain it in details, so that it'll be easily to
  111. keygen the crackme. What does this loop do ???
  112.  
  113. * First loop : characters used from SiFLyiNG are S(1) and N(len-1-1)
  114.                                         
  115.             movzx eax, byte ptr [eax+esi-01] ; EAX = 53h = value of 'S'
  116.             mov dword ptr [ebp-08], eax      ; [EBP-08] = EAX = 53h
  117.             movzx eax, byte ptr [eax+edx-01] ; EAX = 47h = value of 'N'
  118.             and dword ptr [ebp-08], eax      ; [EBP-08] = 53h AND 4Eh = 42h
  119.             add ebx, dword ptr [ebp-08]      ; EBX = EBX + [EBP-08]
  120. before the first loop, EBX=B953E0h, so EBX = EBX+[EBP-08]=B953E0h+42h=B95422h
  121.             imul ebx, esi                    ; EBX = EBX * 1
  122.             EBX>0 so it jumps to 004272C8 and [EBP-0C]-1 = 8-1 = 7
  123. and 7<>0 so it loops another time and we get :
  124.  
  125. * Second Loop : characters used are i(2) and i(len-2-1)
  126.  
  127.             movzx eax, byte ptr [eax+esi-01] ; EAX = 69h = value of 'i'
  128.             mov dword ptr [ebp-08], eax      ; [EBP-08] = EAX = 69h
  129.             movzx eax, byte ptr [eax+edx-01] ; EAX = 69h = value of 'i'
  130.             and dword ptr [ebp-08], eax      ; [EBP-08] = 69h AND 69h = 69h
  131.             add ebx, dword ptr [ebp-08]      ; EBX = EBX + [EBP-08]
  132. so EBX = B95422h + 69h = B9548Bh
  133.             imul ebx, esi                    ; EBX=EBX*2=172A916h
  134.         EBX>0 so it jumps to 004272C8 and [EBP-0C]-1 = 6
  135. 6 <> 0 so it loops another time...
  136.  
  137. * Last Loop : characters used from name are G(last char), but char(len-len-1)
  138. doesn't exist so :
  139.  
  140.             and dword ptr [ebp-08], eax      ; result is 00
  141.             add ebx, dword ptr [ebp-08]      ; EBX doesn't change=40B42778h
  142.             imul ebx, esi                    ; EBX * 8 = 05A13BC0h
  143.  
  144. Thus, at the end of the loop we have : EBX=05A13BC0h
  145.  
  146.         Let's summarizes what the loop makes in general:
  147.  
  148. EBX = B953E0 before the first loop
  149.  
  150.         For i = 1 to lenght of name:
  151. 1. Takes value of char(i)
  152. 2. Takes value of char(len-i-1)
  153. 3. Logical AND between these two values
  154. 4. The result is add to EBX
  155. 5. EBX=EBX*i
  156. 6. There is a test: EBX>0 ?           
  157.  
  158.    What does it mean ??? this test check if EBX<8000 0000h... why this value ?
  159. To see why, make these three examples:
  160.         type '? 7FFFFFFF' in Softice : you see the value in hexa and decimal
  161.         type '? 80000000':you see the value in hexa and in decimal and
  162.                 something between brackets
  163.         type '? 80000001';you see the hex and dec value, and something strange
  164.                 between brackets:decimal signed value with a minus sign.
  165.    You understand now ? All hexa values upper to 80000000 and inferior or
  166. equal to FFFFFFFFh are negative. 80000000 is the maximum negative number
  167. and FFFFFFFF the minimum (it's equal to -1). That's why the prog check if
  168. EBX is superior or equal to 0, and in the other case it takes the two's
  169. complement of EBX. Remember it, that could be important for keygening...
  170.    So, we have the two case: 
  171.  
  172.         Yes:            |                No:
  173. (2356574h for example)  |        (80001234h for example or FF123456h)
  174. 7. Next step            |     7. Neg EBX means EBX=-EBX (reverse the sign)
  175.                         |
  176.  
  177. 8. Next loop (means i=i+1)
  178.  
  179.         I think it's understandable enough now... Let's see what happens
  180. afterwards :
  181.  
  182. :004272CE mov eax, ebx          ; eax = ebx
  183. :004272D0 imul ebx              ; eax = eax * ebx = ebx²
  184. :004272D2 mov ebx, eax          ; ebx = eax
  185. :004272D4 lea edx, dword ptr [ebp-14]
  186. :004272D7 mov eax, ebx          ; eax =ebx
  187. :004272D9 call 004054EC         ; this call converts eax to a string
  188. :004272DE mov eax, dword ptr [ebp-14]
  189. :004272E1 push eax              ; push the converted string
  190. :004272E2 lea edx, dword ptr [ebp-10]
  191. :004272E5 mov eax, dword ptr [edi+000001BC]
  192. :004272EB call 00411AC8         ; this call gets the entered serial
  193. :004272F0 mov edx, dword ptr [ebp-10] ; edx points to the serial
  194. :004272F3 pop eax                     ; eax points to the converted string
  195. :004272F4 call 00403490         ; comparison between the two strings
  196. :004272F9 jne 00427312          ; jump to bad cracker if they are differents
  197.  
  198.         Hummm... i think it's clear, doesn't it ??? The famous converted
  199. string is in fact the real serial for the name 'SiFLyiNG'. You should find
  200. '-1250816000'. But how has the crackme calculated this value ???
  201.         Here are the importants lines :
  202.  
  203. :004272CE mov eax, ebx          ; EAX = EBX = 05A13BC0h
  204. :004272D0 imul ebx              ; EAX = 05A13BC0h * 05A13BC0h = B5721000h
  205. :004272D2 mov ebx, eax          ; EBX = B5721000h
  206. :004272D4 lea edx, dword ptr [ebp-14]
  207. :004272D7 mov eax, ebx          ; EAX = B5721000h
  208. :004272D9 call 004054EC         ; this call converts eax to a string
  209. :004272DE mov eax, dword ptr [ebp-14] ; EAX points to the Valid Serial
  210. :004272E1 push eax              ; Push the valid serial
  211.  
  212.         A simple EBX=EBX*EBX is used. But we have EBX=B5721000h.
  213. Let's try to convert it in SoftIce :
  214.  
  215. '? B5721000' and we see :
  216.  
  217. B5721000  3044151296 (-1250816000)
  218.  
  219. So this conversion is signed. Instead of getting 3044151296 as we could have
  220. thought, we finally have -1250816000. This is very important to make a
  221. keygen.
  222.  
  223. ____________________________________________________________________________
  224.  
  225. The end...
  226.  
  227.         I hope this tut was useful... and most of all understandable !!! I
  228. prefered to detail the routine in order to make a keygen because i think
  229. it's more interesting that serial sniffing, which is here quite easy.
  230.         Now try to make your own keygen ! and if you have questions, critics
  231. or anything else, just mail me.
  232.         Regards,
  233.                         SiFLyiNG
  234.                                 siflying@ifrance.com
  235.  
  236.  
  237.         Greetz : ACiD BuRN, Eternal Bliss, Magic Raphoun, Lucifer48
  238.                 Skymarshall, Volatility, VisionZ, AB4DS, Liquid
  239.                 and all the authors of crackme and tutorials...
  240.  
  241. PS : i'm looking for Win32asm source for keygen and crackme... if you have
  242.         some please send them to me...
  243.  
  244.        
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.         
  252.  
  253.  
  254.  
  255.  
  256.